package com.ruoyi.park.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.park.domain.WyClean;
import com.ruoyi.park.service.IWyCleanService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 保洁管理Controller
 *
 * @author cjie
 * @date 2021-07-22
 */
@Api(tags = " 保洁管理")
@RestController
@RequestMapping("/wyClean")
public class WyCleanController extends BaseController {
    @Autowired
    private IWyCleanService wyCleanService;

    /**
     * 查询保洁管理列表
     */
    @ApiOperation(value="查询保洁管理列表", notes="查询保洁管理列表")
    @PreAuthorize(hasPermi = "park:wyClean:list")
    @GetMapping("/list")
    public TableDataInfo list(WyClean wyClean) {
        startPage();
        List<WyClean> list = wyCleanService.selectWyCleanList(wyClean);
        return getDataTable(list);
    }

    /**
     * 导出保洁管理列表
     */
    @ApiOperation(value="导出保洁管理列表", notes="导出保洁管理列表")
    @PreAuthorize(hasPermi = "park:wyClean:export")
    @Log(title = "保洁管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyClean wyClean) throws IOException {
        List<WyClean> list = wyCleanService.selectWyCleanList(wyClean);
        ExcelUtil<WyClean> util = new ExcelUtil<WyClean>(WyClean.class);
        util.exportExcel(response, list, "保洁管理数据");
    }
    /**
     * 获取保洁管理详细信息
     */
    @ApiOperation(value="获取保洁管理详细信息", notes="获取保洁管理详细信息")
    @PreAuthorize(hasPermi = "park:wyClean:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(wyCleanService.selectWyCleanById(id));
    }

    /**
     * 新增保洁管理
     */
    @ApiOperation(value="新增保洁管理", notes="新增保洁管理")
    @PreAuthorize(hasPermi = "park:wyClean:add")
    @Log(title = "保洁管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyClean wyClean) {
        return toAjax(wyCleanService.insertWyClean(wyClean));
    }

    /**
     * 修改保洁管理
     */
    @ApiOperation(value="修改保洁管理", notes="修改保洁管理")
    @PreAuthorize(hasPermi = "park:wyClean:edit")
    @Log(title = "保洁管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyClean wyClean) {
        return toAjax(wyCleanService.updateWyClean(wyClean));
    }

    /**
     * 删除保洁管理
     */
    @ApiOperation(value="删除保洁管理", notes="删除保洁管理")
    @ApiImplicitParam(name = "ids", value = "保洁管理ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "park:wyClean:remove")
    @Log(title = "保洁管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(wyCleanService.deleteWyCleanByIds(ids));
    }
}
